<?php
/*
 * 初始化View
*/

class Edm_Application_Resource_View extends Zend_Application_Resource_ResourceAbstract {
    protected $_view;

    public function init() {
        if (null === $this->_view) {
            /*
             * 获取 Application,ini 中的配置
            */
            $options = $this->getOptions();
            $view = new Zend_View();
            if (!empty($options['params'])) {
                foreach ($options['params'] as $key => $value) {
                    $view->$key = $value;
                }
            }

            /*
             * viewRenderer 动作助手
            */
            $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');

            /*
             * 保存配置好的视图对象
            */
            $viewRenderer->setView($view);
            $this->_view = $view;
        }
        return $this->_view;
    }
}